@extends('backstage.layout.master')
@section('title', '产品列表')
@section('style')
    <style>
        a{
            cursor: pointer;
        }
    </style>
@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>

            <li class="active">
                权限列表
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="page-header">
            <h1>
                权限列表
            </h1>
        </div>
        <div class="row">
            <div id="data-table_filter" class="dataTables_filter"  style="float: left;">
                <label>查询:
                    <input type="search" class="" value="{{$display_name}}" placeholder="只能查顶级权限" aria-controls="data-table" onchange="changeName(this.value)">
                </label>
            </div>
            <div class="col-xs-12">
                <a href="backstage/permissions/add">
                    <button class="btn btn-danger add-btn-danger" style="float: right;">新增权限</button>
                </a>
            </div>
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="table-responsive">
                    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>权限名称</th>
                            <th>权限</th>
                            <th>描述</th>
                            <th>操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        @foreach ($permissions as $permission)
                        <tr>
                            <td>{{$permission->id}}</td>
                            <td>{{$permission->display_name}}</td>
                            <td>
                                {{$permission->name}}
                            </td>
                            <td>{{$permission->description}}</td>

                            <td>
                                <a class="blue" href="backstage/permissions/update/{{$permission->id}}">编辑</a>
                                <a class="red" href="backstage/permissions/delete/{{$permission->id}}" onclick="return confirm('确认删除吗？');">删除</a>
                            </td>
                        </tr>
                        @foreach($permission->child as $item)
                            <tr>
                                <td>{{$item->id}}</td>
                                <td>┗━{{$item->display_name}}</td>
                                <td>
                                    {{$item->name}}
                                </td>
                                <td>{{$item->description}}</td>

                                <td>
                                    <a class="blue" href="backstage/permissions/update/{{$item->id}}">编辑</a>
                                    <a class="red" href="backstage/permissions/delete/{{$item->id}}" onclick="return confirm('确认删除吗？');">删除</a>
                                </td>
                            </tr>
                            @foreach($item->child as $p)
                                <tr>
                                    <td>{{$p->id}}</td>
                                    <td>&nbsp;&nbsp;&nbsp;┗━{{$p->display_name}}</td>
                                    <td>
                                        {{$p->name}}
                                    </td>
                                    <td>{{$p->description}}</td>

                                    <td>
                                        <a class="blue" href="backstage/permissions/update/{{$p->id}}">编辑</a>
                                        <a class="red" href="backstage/permissions/delete/{{$p->id}}" onclick="return confirm('确认删除吗？');">删除</a>
                                    </td>
                                </tr>
                            @endforeach
                        @endforeach
                        @endforeach
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="dataTables_info" id="sample-table-2_info"></div>
                    </div>
                    <div class="col-sm-6">
                        <div class="dataTables_paginate paging_bootstrap">
                            <?php echo $permissions->render(); ?>
                        </div>
                    </div>
                </div>
                            <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
    <script type="text/javascript">
        function changeName(display_name){
            window.location.href="/backstage/permissions/list/?display_name="+display_name;
        }
    </script>
@stop